package com.gui.entity;

import lombok.Data;

/**
 * 前后端 同一返回结果集
 */
@Data
public class R<T> {
    private Integer code;
    private String msg;
    private T data;


    public R() {
        this.code = RCode.OK;
        this.msg = "操作成功";
    }

    public R(T data) {
        this.code = RCode.OK;
        this.msg = "操作成功";
        this.data = data;
    }

    public static R fail(){
        R objectR = new R<>();
        objectR.msg= "操作失败";
        objectR.code = RCode.ERROR;
        return objectR;
    }

    public static R fail(Object data){
        R objectR = new R<>();
        objectR.msg= "操作失败";
        objectR.code = RCode.ERROR;
        objectR.data = data;
        return objectR;
    }


    public R(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


}
